const fs = require("fs")
const path = require("path")

// 可写流
const ws = fs.createWriteStream(path.resolve(__dirname, "./5.txt"))

const text = `床前明月光
疑是地上霜
举头望明月
低头思故乡
`

text.split("\n").forEach((line) => {
    ws.write(line + "\n")
})

ws.on("finish", () => {
    console.log("写入完成")
})

ws.end() // 结束写入